package com.wx.chapter14.set_;

import java.util.HashSet;

/**
 * @Author : 佩萁
 * Description :
 * @Create : 2023/7/30 - 18:16
 */
public class HashSetStructure {
    public static void main(String[] args) {
        //模拟一个HashSet的底层(HashMap的底层结构)
        //创建一个数组，类型是Node[]的
        HashSet hashSet = new HashSet();
        Node[] tables = new Node[16];
        Node john = new Node("john", null);
        tables[2] = john;
        Node jack = new Node("jack", null);
        john.next = jack;//将jack挂载到john
        Node rose = new Node("Rose", null);
        jack.next = rose;// 将rose 结点挂载到jack
        Node lucy = new Node("lucy", null);
        tables[3] = lucy; // 把lucy 放到 table表的索引为3的位置.
    }
}

class Node {//结点，存储数据，从而可以用来形成链表
    Object item;//存放数据
    Node next;//指向下一个结点

    public Node(Object item, Node next) {
        this.item = item;
        this.next = next;
    }
}